//eslint-disable-next-line
import React from 'react';
import { useHistory } from "react-router";
import { Form, Input, Button, message } from 'antd';
import { useAdmin } from "../../../hook/getAdmins";
import { useEffect } from 'react';
import { useParams } from 'react-router';
// eslint-disable-next-line
export default () => {
    const { _id } = useParams();

    const [oneAdmins, { changeAdmins }] = useAdmin();
    useEffect(() => {
    }, [])

    const layout = {
        labelCol: {
            span: 8,
        },
        wrapperCol: {
            span: 8,
        },
    };
    const tailLayout = {
        wrapperCol: {
            offset: 10,
            span: 8,
        },
    };
    const history = useHistory();
    const onFinish = async ({ adminName, phone, adminPassword }) => {
        const status = await changeAdmins({ adminName, phone, adminPassword, _id })
        if (status) {
            message.success("添加完成,即将跳转...", 1, () => {
                history.push("/info/admins")
            });
        }

    }

    return (
        <Form
            style={{
                marginTop: "30px"
            }}
            {...layout}
            name="control-ref"
            initialValues={oneAdmins}
            onFinish={onFinish}>
            <Form.Item

                label="adminName"
                name="adminName"
                rules={[
                    {
                        required: false,
                    },
                ]}
            >
                <Input />
            </Form.Item>
            <Form.Item

                label="adminPassword"
                name="adminPassword"
                rules={[
                    {
                        required: false,
                    },
                ]}
            >
                <Input />
            </Form.Item>
            <Form.Item

                label="phone"
                name="phone"
                rules={[
                    {
                        required: false,
                    },
                ]}
            >
                <Input />
            </Form.Item>

            <Form.Item {...tailLayout}>
                <Button type="primary" htmlType="submit">
                    提交
                </Button>

            </Form.Item>
        </Form>)
}